package com.neuedu.javase.myex;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.myex 
 * date:   2025/10/29   9:58  
 * 描述:  
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class UseThrows {


    //使用  throws主动的抛出异常
    // public static void  readTxt()   throws FileNotFoundException,IOException {
    public static void  readTxt()   throws IOException {



        FileInputStream fileInputStream = new FileInputStream(new File("D:\\upload", "ab.txt"));

        byte bytes[] = new byte[1024];
        int len = -1;
        while (  (len = fileInputStream.read(bytes)) != -1){
            System.out.println(new String(bytes,0,len));
        }



    }


    public static void main(String[] args) {

        // 在main方法中使用try catch
        try {
            readTxt();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }



}
